//package com.sskj.mqtt.mica;
//
//import lombok.extern.slf4j.Slf4j;
//import net.dreamlu.iot.mqtt.codec.MqttQoS;
//import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.nio.charset.StandardCharsets;
//
//@Slf4j
//@Service
//public class MicaMqttService {
//
//    @Resource
//    private MqttClientTemplate mqttClientTemplate;
//
//    public String sub(String topicFilter) {
//        mqttClientTemplate.subQos2(topicFilter, (context, topic, message, payload) -> {
//            log.info("topic:" + topic);
//            log.info(new String(payload, StandardCharsets.UTF_8));
//        });
//        return "success";
//    }
//
//    public String publish(String topic, String msg){
//        boolean flag = mqttClientTemplate.publish(topic, msg.getBytes(StandardCharsets.UTF_8), MqttQoS.EXACTLY_ONCE);
//        return flag ? "success" : "fail";
//    }
//}
